package TrafficControlSystem.TrafficServer;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;

import TrafficControlSystem.Common.Car;
import TrafficControlSystem.Common.CarsInfo;
import TrafficControlSystem.Common.OKResponse;
import TrafficControlSystem.Common.Response;
import TrafficControlSystem.Common.SETCARSRequest;

public class ConnectionTest {
	public static void main(String args[]) {
		Socket socket;
		try {
			socket = new Socket("localhost", 5001);
			
			ArrayList<Car> cars = new ArrayList<Car>();
			cars.add(new Car(10, 10));
			
			CarsInfo carsInfo = new CarsInfo(cars);			
			
			SETCARSRequest request = new SETCARSRequest(socket, carsInfo);
			request.send();
			System.out.println("Waiting for response");
			OKResponse response = (OKResponse) Response.getFrom(socket);
			if (response != null)
				System.out.println("OK");
			socket.close();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
}
